import time
from time import sleep

import requests
import webbrowser

from selenium import webdriver
from selenium.webdriver.common.by import By

# response = requests.get('file:///path/to/index.html')
# html_content = response.text

# webbrowser.open('index.html')

driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(1)
driver.get("file:///E:/selenium%E9%A1%B9%E7%9B%AE001/pythonProject2/index.html")

button_able = driver.find_element(By.XPATH,'//*[@id="form"]/div/div[2]/input')
button_able_true = button_able.get_attribute('abled')
sleep(5)
i = 0
while True:
    button_able = driver.find_element(By.XPATH, '//*[@class="button_confire"]')
    # driver.find_element(By.XPATH, "//span[contains(.,'新增出口订单')]").click()
    button_able_true = button_able.get_attribute('abled')
    if button_able_true == 'true':
        driver.get('https://v220-supplier.21silkroad.com/login')
        break
    elif i==100:
        js = 'alert("弹窗提示！已超时，页面已关闭");'
        driver.execute_script(js)
        driver1 = driver.switch_to_alert()
        sleep(2)
        driver1.accept()
        driver.close()
        driver.quit()
        break
    else:
        driver.close()
        driver.quit()
        break
    i=i+2
    sleep(2)
